Welcome to the ultimate guide of essential Linux commands! Each command here is explained in about 50 words, including syntax and usage, to help beginners and enthusiasts navigate Linux systems confidently.
Allows users to run programs with the security privileges of another user (by default, the superuser). It's commonly used for administrative tasks such as installing software. Usage example: sudo apt install package_name. It requires authentication and logs every command run through it for security auditing.
Prints the full pathname of the current working directory. It's helpful to confirm where you are within the Linux file system hierarchy. Simply type pwd to get an absolute path from the root (/). No options are necessary for basic use.
Changes the current directory to another. You can move using relative paths (e.g., cd ../) or absolute paths (e.g., cd /home/user). Typing cd without arguments takes you to your home directory. Essential for navigating the file system.
Lists directory contents. You can add options like -l (long format), -a (include hidden files), and -h (human-readable file sizes). Usage: ls -lah. It provides quick insight into file structure and permissions.
Concatenates and displays file content. It’s often used to view text files quickly. Example: cat filename.txt. You can also use it to combine multiple files or redirect output using > and >> operators.
Copies files or directories. Use cp file.txt /destination/ to copy files and cp -r folder /destination/ for directories. It's useful for backing up data or moving data between locations.
Moves or renames files and directories. Syntax: mv oldname newname. It’s useful for organizing files and renaming without duplication. For moving between directories, include a path: mv file.txt /path/to/destination.
Creates new directories. Add -p to create nested directories in a single command. Example: mkdir -p /new/folder/path. Ensure you have appropriate permissions in the target location.
Removes empty directories. It won’t work if the directory contains files. Use rmdir directory or rmdir -p parent/child to remove nested directories.
Deletes files and directories. Add -r for directories and -f to force deletion without prompt. Example: rm -rf folder. Be cautious—this action is irreversible unless backups exist.
Creates a new empty file or updates the timestamp of an existing file. Commonly used in scripting to create files quickly. Example: touch newfile.txt. You can also create multiple files at once using space-separated names.
Searches for files by name using a prebuilt index. Much faster than find, but may not reflect real-time changes unless updated with updatedb. Example: locate file.txt.
Recursively searches directories for files matching given criteria such as name, type, or size. Example: find /home -name file.txt. Powerful for deep searches.
Searches for text patterns in files. Useful for logs and large text files. Example: grep 'error' logfile.log. Supports regular expressions and recursive search with -r.
Shows disk usage of mounted filesystems. Add -h for human-readable format. Example: df -h. Useful to check if a partition is full.
Displays size of directories and files. Use du -sh folder/ to get a summary of folder size. Helpful for tracking down disk space usage.
Displays the first few lines of a file. Default is 10 lines. Use -n to specify line count. Example: head -n 5 file.txt.
Displays the last lines of a file. Use tail -f to follow updates live, great for monitoring logs. Example: tail -f /var/log/syslog.
Compares two files line by line. Useful in development to detect changes. Example: diff old.txt new.txt. Use -u for unified format.
Archives files into a .tar file. Add -z for gzip compression. Example: tar -czvf archive.tar.gz folder/. Also used to extract archives.
Changes file permissions. Use numbers (e.g., 755) or symbols (e.g., u+x). Example: chmod 755 script.sh. Essential for setting execute permissions.
Changes the owner and group of a file. Example: chown user:group file.txt. Requires sudo. Useful when managing shared environments.
Displays background jobs started from the current terminal. You can bring jobs to foreground using fg. Useful in multitasking with terminal processes.
Sends a signal to a process, usually to stop it. Use kill PID or kill -9 PID to forcefully terminate. Check PID using ps.
Tests connectivity to another host. It sends ICMP echo requests and shows the response time. Example: ping google.com.
Downloads files from the web via terminal. Works with HTTP, HTTPS, and FTP. Example: wget https://example.com/file.zip. Can resume downloads with -c.
Shows system information like kernel name, OS, and architecture. Example: uname -a. Useful for checking system specs.
Displays live system resource usage and running processes. Press q to quit. Provides CPU, memory, and process monitoring.
Shows the list of previously executed commands in the shell. Useful for recalling or reusing commands. Clear history with history -c.
Displays the manual page for commands. Example: man ls. Learn options and syntax for any Linux command.
Prints strings to the terminal. Often used in scripts for output. Example: echo "Hello World".
Compresses (zip) and extracts (unzip) zip files. Example: zip archive.zip file.txt and unzip archive.zip.
Displays or sets the system hostname. Example: hostname. Useful in networking configurations and system identification.
Adds or deletes user accounts. Use useradd username and userdel username. Requires root privileges.
Package management command for Debian-based systems. Example: sudo apt-get install packagename. Use update and upgrade to manage system packages.
Text editors used in the terminal. nano is user-friendly, vi is powerful but complex. Use nano file.txt to start editing quickly.
Create shortcuts for commands using alias. Remove them with unalias. Example: alias ll='ls -la'.
Switches to another user account. Use su - username for login shell. Default is root if no username is provided.
An interactive process viewer, similar to top but with color and easier navigation. Use arrow keys and function keys for controls.
Displays a snapshot of active processes. Use ps aux to see all system processes with detailed information.
Thank you! Share this page with your friends who are interested in Linux!